package com.jboost.hyk.common.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.jboost.common.constant.CommonConstant;
import com.jboost.common.constant.EnumInterface;

/**
 *@ClassName
 *@Description
 *@Author cxn
 *@Date 2022-10-11
 *@Version
 **/
public enum ExcelCheckStatusEnum implements EnumInterface {
//  状态： success-成功；warning-警告；fail-失败
    SUCCESS("success", "成功"),
    WARNING("warning", "警告"),
    FAIL("fail", "失败");

    ExcelCheckStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @EnumValue
    @JsonValue    //标记响应json值
    private final String code;
    private final String desc;

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
    public static ExcelCheckStatusEnum getByCode(String code) {
        ExcelCheckStatusEnum[] enums = ExcelCheckStatusEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if(enums[i].code.equals(code)){
                return enums[i];
            }
        }
        return null;
    }
    public static String getDescByCode(String code) {
        if(null == code){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        ExcelCheckStatusEnum status = ExcelCheckStatusEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getDesc();
    }

    @Override
    public String desc() {
        return this.desc;
    }

    @Override
    public Integer value() {
        return null;
    }

    @Override
    public String code() {
        return this.code;
    }

}
